<admintpl file="header" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.cityselect.js"></script>
</head>
<style>
    .input_edit{
        width:120px;
    }
</style>
<body>
<div class="wrap js-check-wrap">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li <if condition="trim($_GET['a']) eq 'index'">class="active"</if>><a href="{:U('company/index')}">公司列表</a></li>
            <li class="active"><a href="{:U('company/addCompany')}">编辑公司信息</a></li>
        </ul>
        <form method="post" class="form-horizontal js-ajax-form" action="{:U('Company/editCompany')}" >

            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;"><span style="color: red;">*</span> 所在地区：</label>
                <div id="city_1">
                    <select class="prov" name="prov"></select>
                    <select class="city" name="city" disabled="disabled"></select>
                </div>
            </div>

            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;"><span style="color: red;">*</span> 公司名称：</label>
                <div class="span4">
                    <input type="text" name="company_name" value="{$company_info.name}">
                </div>
            </div>

            <div class="control-group">
                <label class="span2 control-label" style="width: 90px;">公司简介：</label>
                <div class="span7">
                    <textarea style="width: 556px; height: 70px;" name="introduction">{$company_info.introduction}</textarea>
                </div>
            </div>

            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;">联系电话：</label>
                <div class="span4">
                    <input type="text" name="phone" value="{$company_info.phone}">
                </div>
            </div>
            <input type="hidden" name="company_id" value="{$_GET['company_id']}">
            <div class="form-actions" style="padding-left:260px;">
                <button type="submit" class="btn btn-primary js-ajax-submit" data-type="add">修改</button>
                &nbsp;&nbsp;<a class="btn" href="{:U('Company/index')}">{:L('BACK')}</a>
            </div>
        </form>
        <div class="pagination">{$page}</div>
    </div>

</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
    function add_check(){
        var name = $("input[name='company_name']").val();
        var introduction = $("[name='introduction']").val();
        var flag = false;
        $.ajax({
            type:"post",
            async:false,
            url:"{:U('Admin/Movement/filter_words')}",
            data:'name='+name+'&introduction='+introduction,
            dataType:"text",
            success:function(data){
                if(data){
                    if(confirm('您编辑的内容涉及敏感词'+data+'是否继续操作')){
                        flag= true;
                    }else{
                        flag= false;
                    }
                }else{
                    flag = true;
                }
            }
        });
        return flag;
    }
    $(function () {
        var prov = '{$company_info.prov}' ? '{$company_info.prov}' : '北京';
        var city = '{$company_info.city}' ? '{$company_info.city}' : '';
        $("#city_1").citySelect({
            url:"/public/js/city.js",
            prov: prov, //省份
            city: city, //城市
            nodata:"none" //当子集无数据时，隐藏select
        });
    })
    function html5Reader(file, previewId){
        var file = file.files[0];
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#'+previewId).attr('src', this.result);
        }
    }
    function image_change(fileId, previewId) {
        var pic = document.getElementById(previewId),
            file = document.getElementById(fileId);

        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

        // gif在IE浏览器暂时无法显示
        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
            alert("图片的格式必须为png或者jpg或者jpeg格式！");
            return;
        }
        var isIE = navigator.userAgent.match(/MSIE/)!= null,
            isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

        if(isIE) {
            file.select();
            var realLocalPath = document.selection.createRange().text;

            // IE6浏览器设置img的src为本地路径可以直接显示图片
            if (isIE6) {
                pic.src = realLocalPath;
            }else {
                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
                pic.src = '';
            }
        }else {
            html5Reader(file, previewId);
        }
    }

    $("#picker").click(function(){
        $("#imageFile").click();
    });

    $("#imageFile").change(function(){
        image_change('imageFile', 'imagePreview');
    });
</script>

</body>
</html>